# Create your models here.
from django.db import models
import uuid
import pgvector.django


class KnowledgeBase(models.Model):
    know_base_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    know_base_name = models.CharField(max_length=255, unique=True, verbose_name="知识库名称")
    create_date = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    create_user_id = models.CharField(max_length=255, verbose_name="创建人ID",default='00000000-0000-0000-0000-0000')

    class Meta:
        db_table = 'knowledge_base'  # 可选：自定义表名
        verbose_name = '知识库'
        verbose_name_plural = '知识库列表'

    def __str__(self):
        return self.know_base_name

class File(models.Model):
    file_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    file_name = models.CharField(max_length=255, verbose_name="文件名")
    file_path = models.CharField(max_length=255, verbose_name="文件绝对路径", unique=True)
    file_type = models.CharField(max_length=32, verbose_name= "文件类型/后缀名")
    know_base_id =models.UUIDField()

    class Meta:
        db_table = 'file'
        verbose_name = '文档'
        verbose_name_plural = '文档列表'


class TextVector(models.Model):
    embedding_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    embedding_content = models.TextField()
    embedding_vector = pgvector.django.VectorField(dimensions=768)
    file_id = models.UUIDField()
    know_base_id =models.UUIDField()

    class Meta:
        db_table = 'text_embedding'
        verbose_name = '嵌入向量'
        verbose_name_plural = '嵌入向量列表'

class ImageVector(models.Model):
    # 图片存储可以先写个demo 看一下长度之类的
    embedding_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    img_description = models.TextField(verbose_name="图片描述")
    embedding_vector = pgvector.django.VectorField()
    image_path = models.CharField(max_length=255, verbose_name="图片存储路径")
    file_id = models.UUIDField()
    know_base_id =models.UUIDField()

    class Meta:
        db_table = 'image_embedding'
        verbose_name = '图片向量'
        verbose_name_plural = '图片向量列表'


